(&mut CV::Table(ref mut old, _), CV::Table(ref mut new, _)) => {
let new = mem::replace(new, HashMap::new());
for (key, value) in new.into_iter() {
- match old.entry(key) {
- Occupied(mut entry) => { try!(entry.get_mut().merge(value)); }
+ match old.entry(key.clone()) {
+ Occupied(mut entry) => {
+ let path = value.definition_path().clone();
+ let entry = entry.get_mut();
+ try!(entry.merge(value).chain_error(|| {
+ human(format!("failed to merge key `{}` between \
+ files:\n \
+ file 1: {}\n \
+ file 2: {}",
+ key,
+ entry.definition_path().display(),
+ path.display()))
+
+ }));
+ }
Vacant(entry) => { entry.insert(value); }
};
}
-use support::{project, execs};
+use support::{project, execs, cargo_dir};
use hamcrest::assert_that;
fn setup() {}
"#)
.file("src/lib.rs", "")
.file(".cargo/config", r#"
- target = "foo"
+ [target]
+ nonexistent-target = "foo"
"#);
- assert_that(foo.cargo_process("build").arg("-v"),
+ assert_that(foo.cargo_process("build").arg("-v")
+ .arg("--target=nonexistent-target"),
execs().with_status(101).with_stderr("\
-expected table for configuration key `target`, but found string in [..]config
+expected table for configuration key `target.nonexistent-target`, but found string in [..]config
"));
});
"));
});
+test!(bad5 {
+ let foo = project("foo")
+ .file(".cargo/config", r#"
+ foo = ""
+ "#)
+ .file("foo/.cargo/config", r#"
+ foo = 2
+ "#);
+ foo.build();
+ assert_that(foo.process(cargo_dir().join("cargo")).arg("new")
+ .arg("-v").arg("foo").cwd(foo.root().join("foo")),
+ execs().with_status(101).with_stderr("\
+Failed to create project `foo` at `[..]`
+
+Caused by:
+ Couldn't load Cargo configuration
+
+Caused by:
+ failed to merge key `foo` between files:
+ file 1: [..]foo[..]foo[..]config
+ file 2: [..]foo[..]config
+
+Caused by:
+ expected integer, but found string
+"));
+});
test!(bad_cargo_config_jobs {
let foo = project("foo")